<template>
  <view class="">
    <view v-for="item in list" :key="item.id" class="bg-white mt-12">
      <view class="flex-ba h-36 text-12 px-14 hair--b">
        <view class="">订单编号：{{ item.order_sn }}</view>
        <view class="text-info">{{ item.create_date }}</view>
      </view>
      <view class="flex-a py-10 px-14">
        <image class="goods-logo" :src="item.object_logo" />
        <view class="flex-1 flex-vb h-70">
          <view class="h-40 leading-20 ellipsis-2">{{ item.object_name }}</view>
          <view class="flex-ba text-12">
            <view class="text-error">￥{{ item.price }}</view>
            <view class="text-info">{{ item.end_date }}到期</view>
          </view>
        </view>
      </view>
    </view>
    <uni-load-more :status="$f.getLoading(loading)" />
  </view>
</template>

<script>
export default {
  data() {
    return {
      page: 1,
      loading: 0,
      list: [],
      limit: 10
    }
  },
  onLoad() {
    this.getList()
  },
  onReachBottom() {
    this.getList()
  },
  methods: {
    getList() {
      if (this.loading) return
      this.loading = 1
      this.$f.post('api/userOrder', {
        page: this.page,
        limit: this.limit
      }).then(res => {
        this.loading = this.limit > res.data.length ? 2 : 0
        if (res.data.length) {
          this.list = [...this.list, ...res.data]
          this.page += 1
        }
      })
    }
  }
}
</script>

<style lang="scss">
	.goods-logo {
		width: 180rpx;
		height: 140rpx;
		margin-right: 16rpx;
		border-radius: 12rpx;
	}
</style>
